package com.woniu.controller;

import com.woniu.entity.MedSurgeryApplication;
import com.woniu.service.ISurgeryAppService;
import com.woniu.utils.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;

@RestController
@RequestMapping("/surgery-app")
public class SurgeryAppController {
    @Resource
    private ISurgeryAppService surgeryAppService;
    @GetMapping
    public ResponseUtil list(){
        ResponseUtil result = surgeryAppService.listSurgeryApplications();
        return result;
    }
    @PostMapping
    public ResponseUtil addRecord(@RequestBody MedSurgeryApplication
                                              medSurgeryApplication) throws ParseException {
        ResponseUtil result = surgeryAppService
                .addRecord(medSurgeryApplication);
        return result;
    }
    @GetMapping("/patient/{patientId}")
    public ResponseUtil listByPatient(@PathVariable Integer patientId) {
        ResponseUtil result = surgeryAppService.listSurgeryApplicationsByPatientId(patientId);
        return result;
    }
    @PutMapping
    public ResponseUtil update(@RequestBody MedSurgeryApplication record) {
        ResponseUtil result = surgeryAppService.update(record);
        return result;
    }
}
